package cn.lookup.controller;

import cn.lookup.pojo.User;
import cn.lookup.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@RestController
public class HelloController {
    @Autowired
    private DataSource dataSource;
    @Autowired
    private UserService userService;
    @Value("${test.name}")
    private String test;

    @GetMapping("/hello")
    public String hello() {
        System.out.println("dataSource" + dataSource);
        //System.out.println("test.name" + test);
        return "测试controller";
    }
    @GetMapping("/user/{id}")
    public User getUserById(@PathVariable(name="id") int id) {
        User user = userService.queryUserById(id);
        return user;
    }
}
